<?php

namespace App\Http\Controllers\Home;

use Illuminate\Http\Request;
use DB;
use App\Http\Requests;
use App\Http\Controllers\Controller;

class Homelistcontroller extends Controller
{
    public function getLlist(Request $request)
    {   

         $id = $request->input('id');

         $path = DB::table("project_type")->get();
   
         function fen($id,$path) {

            global $arr;

            foreach($path as $v => $k) {

               if($k->id == $id ) {

                   if(substr_count($k->path,',') == 2) {

                     $arr[] = $id;

                  } else {

                      foreach($path as $v => $k ) {

                        if($k->pid == $id) {

                            fen($k->id,$path);
                        }
                     }
                  } 
                   return $arr;  
               }
            }
         }

        $arr = fen($id,$path);

        foreach($arr as $k => $v) {

         $row[] = DB::table('project_goods')->where('tid',$v)->get();

        }

        return view('home/list',['row'=>$row]);
         
         
      }
}
